<template>
  <a-card :bordered="false">
    <detail-list title="项目信息">
      <detail-list-item term="项目编号">{{ projectInfo.xmbh }}&nbsp;</detail-list-item>
      <detail-list-item term="项目名称">{{ projectInfo.xmmc }}&nbsp;</detail-list-item>
      <detail-list-item term="项目类别">{{ projectInfo.xmlbmc }}&nbsp;</detail-list-item>
      <detail-list-item term="项目起止时间">{{ projectInfo.kssj && projectInfo.kssj.format('YYYY-MM-DD') }}&nbsp;-&nbsp;{{ projectInfo.jssj && projectInfo.jssj.format('YYYY-MM-DD') }}</detail-list-item>
      <detail-list-item term="项目类型">{{ projectInfo.xmlxmc }}&nbsp;</detail-list-item>
      <detail-list-item term="项目经费">{{ projectInfo.xmjf }}万元&nbsp;</detail-list-item>
      <!-- <detail-list-item term="项目说明">{{ projectInfo.note }}&nbsp;</detail-list-item> -->
    </detail-list>
    <detail-list :col="1">
      <detail-list-item term="项目说明">{{ projectInfo.note }}&nbsp;</detail-list-item>
    </detail-list>
    <detail-list title="导师信息">
      <detail-list-item term="姓名">{{ projectInfo.dsxm }}&nbsp;</detail-list-item>
      <detail-list-item term="性别">{{ projectInfo.xbmc }}&nbsp;</detail-list-item>
      <detail-list-item term="出生日期">{{ projectInfo.csrq && projectInfo.csrq.format('YYYY-MM-DD') }}&nbsp;</detail-list-item>
      <detail-list-item term="所在院系">{{ projectInfo.ssyxmc }}&nbsp;</detail-list-item>
      <detail-list-item term="专业">{{ projectInfo.sszymc }}&nbsp;</detail-list-item>
      <detail-list-item term="邮箱">{{ projectInfo.dzxx }}&nbsp;</detail-list-item>
      <detail-list-item term="电话">{{ projectInfo.lxdh }}&nbsp;</detail-list-item>
    </detail-list>
    <a-form :form="form">
      <a-row>
        <a-col :md="8" :sm="24">
          <a-form-item
            label="审核结果"
            :labelCol="{span: 7,offset: 1}"
            :wrapperCol="{span: 15, offset: 1}"
          >
            <a-select v-decorator="['shzt',
              {
                rules: [{ required: true, message: '请选择审核结果!' }],
              }]">
              <a-select-option v-if="projectInfo.shzt == '02'" value="21">审核已通过</a-select-option>
              <a-select-option v-if="projectInfo.shzt == '02'" value="22">审核未通过</a-select-option>
              <a-select-option v-if="projectInfo.shzt == '21'" value="23">国际处审核已通过</a-select-option>
              <a-select-option v-if="projectInfo.shzt == '21'" value="24">国际处审核未通过</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <template v-if="projectInfo.shzt == '02'">
          <a-col :md="16" :sm="24">
            <a-form-item
              label="审核说明"
              :labelCol="{span: 7,offset: 1}"
              :wrapperCol="{span: 15, offset: 1}"
            >
              <a-input type="textarea" v-decorator="['shyj',
                {
                  rules: [{ required: true, message: '请填写审核说明!' }],
                }]" :autosize="{ minRows: 4, maxRows: 6 }"/>
            </a-form-item>
          </a-col>
        </template>
        <template>
          <a-col :md="16" :sm="24" v-if="projectInfo.shzt == '21'">
            <a-form-item
              label="审核说明"
              :labelCol="{span: 7,offset: 1}"
              :wrapperCol="{span: 15, offset: 1}"
            >
              <a-input type="textarea" v-decorator="['gjcshyj',
                {
                  rules: [{ required: true, message: '请填写审核说明!' }],
                }]" :autosize="{ minRows: 4, maxRows: 6 }"/>
            </a-form-item>
          </a-col>
        </template>

      </a-row>
      <div class="ant-pro-footer-toolbar">
        <a-button style="float: right;margin-top: 10px;" @click="submit" :loading="loadingBtn" type="primary">提交</a-button>
        <a-button style="float: right;margin-top: 10px; margin-right: 20px;" @click="back">返回</a-button>
      </div>
    </a-form>
  </a-card>
</template>

<script>
import DetailList from '~/tool/DetailList'
import { mapState } from 'vuex'
const DetailListItem = DetailList.Item

export default {
  data () {
    return {
      loadingBtn: false,
      projectInfo: {}
    }
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  computed: {
    ...mapState({
      TYPE0133: state => state.app['TYPE0133']
    })
  },
  components: {
    DetailList,
    DetailListItem
  },
  created () {
    this.$store.dispatch('app/setDictionary', 'TYPE0133')
    this.$api.overseas.projectInfo( this.$route.params.dsbh ).then(res => {
      this.projectInfo = res.data || {}
    })
  },
  methods: {
    submit () {
      this.form.validateFields((err, values) => {
        if (err) {
          return
        }
        this.loadingBtn = true
        if(this.projectInfo.shzt == '02'){
          this.$api.overseas.projectCheck(Object.assign(values, {ids: [this.projectInfo.id]})).then(res => {
            this.$message.success('操作成功')
            this.$router.back()
          }).finally(() => {
            this.loadingBtn = false
          })
        }else{
          this.$api.overseas.projectGJCCheck(Object.assign(values, {ids: [this.projectInfo.id]})).then(res => {
            this.$message.success('操作成功')
            this.$router.back()
          }).finally(() => {
            this.loadingBtn = false
          })
        }

      })
    },
    back () {
      this.$router.back()
    },
    toInfo () {
      this.$router.push(`/overseas/info/${this.projectInfo.dsbh}`)
    }
  }
}
</script>

<style>

</style>
